<!--
 * @Author: shenya
 * @Date: 2023-09-16 09:20:52
 * @Description: 回复评论
-->
<template>
  <el-dialog
    title="评论管理"
    :visible.sync="visible"
    width="60%"
    append-to-body
  >
    <avue-crud
      ref="crud"
      v-model="form"
      class="base-crud"
      :page.sync="page"
      :data="tableData"
      :table-loading="tableLoading"
      :option="commmentOption"
      @on-load="getList"
      @search-change="searchChange"
      @search-reset="searchReset"
    >
      <template
        slot="menu"
        slot-scope="scope"
      >
        <el-button
          type="text"
          @click="restore(scope.row)"
        >
          恢复
        </el-button>
      </template>
    </avue-crud>
  </el-dialog>
</template>
<script>
import { commmentOption } from '@/const/crud/community-content/user';
import crudMixins from '@/mixins/crud';
import { fetchPetRecordComment } from '@/api/core/comment';
export default {
  mixins: [crudMixins],
  props: {
    value: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      form: {},
      tableData: [],
      tableLoading: false,
      commmentOption: commmentOption(),
    };
  },
  computed: {
    visible: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit('input', val);
      },
    },
  },
  methods: {
    //回复
    restore() {},
    //查询分页列表
    // 列表查询
    getList(page, refresh) {
      if (refresh) {
        this.page.current = 1;
        this.page.currentPage = 1;
      }
      this.tableLoading = true;
      fetchPetRecordComment(
        Object.assign(
          {
            current: this.page.currentPage,
            size: this.page.pageSize,
            relativeId: this.id,
          },
          this.searchForm
        )
      )
        .then((response) => {
          this.tableData = response.data.data.records;
          this.page.total = response.data.data.total;
          this.tableLoading = false;
        })
        .catch(() => {
          this.tableLoading = false;
        });
    },
  },
};
</script>
<style lang="scss" scoped></style>
